<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>后台管理-ldbz-shop</title>
    <link rel="stylesheet" href="${request.contextPath}/admin_res/layui-admin/frame/layui/css/layui.css">
    <link rel="stylesheet" href="${request.contextPath}/admin_res/layui-admin/frame/static/css/style.css">
    <link rel="icon" href="${request.contextPath}/admin_res/favicon.ico">
</head>
<body class="login-body body">

<div class="login-box">
    <form class="layui-form layui-form-pane" method="post" action="">
        <div class="layui-form-item">
            <h3>后台登录系统</h3>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号：</label>
            <div class="layui-input-inline">
                <input type="text" name="account" class="layui-input" lay-verify="account" placeholder="账号"
                       autocomplete="off" maxlength="20"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-inline">
                <input type="password" name="password" class="layui-input" lay-verify="password" placeholder="密码"
                       autocomplete="off" maxlength="20"/>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">验证码：</label>
            <div class="layui-input-inline">
                <input type="text" name="code" class="layui-input" lay-verify="code" placeholder="验证码" maxlength="4"/><img
                    src="${sso_web_url}verify/image?uid=${uid}" alt="" id="imageCode">
            </div>
        </div>
        <div class="layui-form-item">
        	<input type="hidden" value="${uid}" name="uid">
            <button type="reset" class="layui-btn layui-btn-danger btn-reset">重置</button>
            <button type="button" class="layui-btn btn-submit" lay-submit="" lay-filter="sub">立即登录</button>
        </div>
    </form>
</div>

<script type="text/javascript" src="${request.contextPath}/admin_res/layui-admin/frame/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {

        // 操作对象
        var form = layui.form
                , layer = layui.layer
                , $ = layui.jquery;

        // 验证
        form.verify({
            account: function (value) {
                if (value == "") {
                    return "请输入用户名";
                }
            },
            password: function (value) {
                if (value == "") {
                    return "请输入密码";
                }
            },
            code: function (value) {
                if (value == "") {
                    return "请输入验证码";
                }
            }
        });

        // 提交监听
        form.on('submit(sub)', function (data) {
            $.post("${request.contextPath}/admin/login" , data.field , function(ret){
            	var json = $.parseJSON(ret);
            	if(json && json.status==200){
	            	location.href = "${request.contextPath}/admin/info" ;
            	}else{
            		layer.msg(json.msg);
            	}
            });
            return false;
        });
        
        //切换验证码
        $("#imageCode").click(function(){
        	var src = $(this).attr("src");
        	$(this).attr("src" , src+"&r="+Math.random())
        });

    });
</script>
</body>
</html>